{% extends 'TopxiaWebBundle:CourseManage:layout.html.twig' %}

{% block title %}{{'课时管理'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'lesson' %}
{% set script_controller = 'course-manage/lesson' %}

{% block main %}

<div class="panel panel-default panel-col lesson-manage-panel"
	data-file-status-url={{path('course_manage_lesson_file_status',{id:course.id})}}>
	<div class="panel-heading">
		<div class="pull-right">

			<button class="btn btn-info btn-sm" id="lesson-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{% if course.type == 'normal' %}{{ path('course_manage_lesson_create', {id:course.id}) }}{% else %}{{ path('live_course_manage_lesson_create', {id:course.id}) }}{% endif %}"><i class="glyphicon glyphicon-plus"></i> {% if course.type == 'normal' %}{{'课时'|trans}}{% else %}{{'直播课时'|trans}}{% endif %}</button>

			{% if course.type == 'normal' or course.type == 'live' %}
				<button class="btn btn-info btn-sm" id="lesson-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_lesson_create_testpaper', {id:course.id}) }}"><i class="glyphicon glyphicon-plus"></i> {{'试卷'|trans}}</button>
			{% endif %}

			<div class="btn-group">
			  <button type="button" class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown">
			    <i class="glyphicon glyphicon-plus"></i> {{setting('default.chapter_name')|default('章'|trans)}}/{{setting('default.part_name')|default('节'|trans)}} <span class="caret"></span>
			  </button>
			  <ul class="dropdown-menu" role="menu">
			    <li>
			      <a href="#" id="chapter-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_chapter_create', {id:course.id}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 {{setting('default.chapter_name')|default('章')}}</a>
			    </li>
			    <li>
			      <a href="#" id="chapter-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_chapter_create', {id:course.id, type:'unit'}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 {{setting('default.part_name')|default('节')}}</a>
			    </li>
			  </ul>
			</div>
		</div>

		{{'课时管理'|trans}}
	</div>

	{% if items is empty %}

	 <div class="empty">{{'暂无课时内容！'|trans}}</div>

	 {% endif %}

	<div class="panel-body">
		<ul class="lesson-list sortable-list" id="course-item-list" data-sort-url="{{ path('course_manage_lesson_sort', {id:course.id}) }}">
			{% for id, item in items %}
			  {% if 'chapter' in id %}
			    {% include 'TopxiaWebBundle:CourseChapterManage:list-item.html.twig' with {chapter: item} %}
			  {% elseif 'lesson' in id  %}
			  	{% include 'TopxiaWebBundle:CourseLessonManage:list-item.html.twig' with {lesson: item, file: files[item.mediaId]|default(null)} %}
			  {#
			  {% elseif  item.type == 'testpaper'  %}
			      {% include 'TopxiaWebBundle:CourseTestpaperManage:list-item.html.twig' with {lesson: item, file: files[item.mediaId]|default(null)} %}
			  #}
			  {% endif %}
			{% endfor %}

		</ul>
	</div>
</div>

{% endblock %}
